#ifndef _OS_TYPES_H
#define _OS_TYPES_H
/*======================== INCLUDES ===============================*/
#include "stdint.h"
/*========================  DEFINES ===============================*/

#define OS_PRIORITY_0 	(uint8_t)0x00
#define OS_PRIORITY_1 	(uint8_t)0x01
#define OS_PRIORITY_2 	(uint8_t)0x02
#define OS_PRIORITY_3 	(uint8_t)0x03
#define OS_PRIORITY_4 	(uint8_t)0x04
#define OS_PRIORITY_5 	(uint8_t)0x05
#define OS_PRIORITY_6 	(uint8_t)0x06
#define OS_PRIORITY_7 	(uint8_t)0x07
#define OS_PRIORITY_8 	(uint8_t)0x08
#define OS_PRIORITY_9 	(uint8_t)0x09
#define OS_PRIORITY_10 	(uint8_t)0x0A
#define OS_PRIORITY_11 	(uint8_t)0x0B
#define OS_PRIORITY_12 	(uint8_t)0x0C

#define OS_MAX_PRIORITY 0x0C

#define OS_MAX_QUEUE_SIZE	(uint8_t)0x14

/*========================  MACROS  ===============================*/

#define TASK(taskID) void taskID(void)

#define DeclareTask(taskID) extern TASK(taskID)
/*======================== TYPEDEFS ===============================*/


/* Offset for the activation */
typedef uint8_t OS_TaskOffsetType;
/* Mask_type for the activation */
typedef uint8_t OS_TaskMaskType;
/* Task Priority type*/
typedef uint8_t OS_TaskPriority;
/* typedef for the stack info */
typedef uint32_t OS_StackInfoType;
/* Typedef for the deadline info */
typedef uint32_t OS_TaskDeadlineType;
/* Callback type for a task */
typedef void (*OS_TaskCallbackType)(void);

/* States of a task */
typedef enum{ 
	SUSPENDED,
	READY,
	RUNNING,
}OS_TaskStateType;

/* Reference to a variable of type Task State Type */
typedef OS_TaskStateType * OS_TaskStateRefType;

/* List of the available tasks */
typedef enum{
	TASK_1MS,
	TASK_4MS,
	TASK_8MS,
	TASK_16MS,
	TASK_32MS,
	TASK_64MS,
	NONE,
}OS_TaskType;

/* Reference to a variable of Task Type */
typedef OS_TaskType * OS_TaskRefType;

/* Status returns type (error codes) */
typedef enum{
	E_OK,
	E_OS_ACCESS,
	E_OS_CALLEVEL,
	E_OS_ID,
	E_OS_LIMIT,
	E_OS_NOFUNC,
	E_OS_RESOURCE,
	E_OS_STATE,
	E_OS_VALUE,
}OS_StatusType;

/* Task control block  */
typedef struct{
	OS_TaskType 		  TaskID;
	OS_TaskPriority 	Priority;
	OS_TaskStateType  State;
	OS_StackInfoType	StackStart;
	OS_StackInfoType	StackEnd;
	OS_TaskDeadlineType		Abs_Deadline;
	OS_TaskDeadlineType		Rel_Deadline;
}OS_TaskControlBlockType;

/* Priority queue definition */
typedef struct{
	OS_TaskType * __far Queue;
	uint8_t 		u8QueueDepth;
	uint8_t			u8index;		
}OS_QueueType;
/*======================= FUNCTIONS ===============================*/
#endif /*_OS_TYPES_H*/